# Contributor: Aiden Grossman <agrossman154@yahoo.com>
# Maintainer: Aiden Grossman <agrossman154@yahoo.com>
pkgname=gmsh
pkgver=4.11.1
pkgrel=0
pkgdesc="Automatic 3D finite element mesh generator"
url="https://gmsh.info/"
# s390x: opencascade
# armv7, armhf: segfaults
# x86: fails tests
arch="all !x86 !armv7 !armhf !s390x"
license="GPL-2.0-or-later" # license lists several exceptions
makedepends="
	cmake
	fltk-dev
	glu-dev
	gmp-dev
	hdf5-dev
	jpeg-dev
	mesa-dev
	opencascade-dev
	samurai
	"
subpackages="$pkgname-doc gmsh-py"
source="https://gmsh.info/src/gmsh-$pkgver-source.tgz"
builddir="$srcdir/$pkgname-$pkgver-source"

build() {
	CFLAGS="$CFLAGS -O2" \
	CXXFLAGS="$CXXFLAGS -O2" \
	cmake -B build -G Ninja \
		-DCMAKE_BUILD_TYPE=None \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DRPATH=OFF \
		-DTESTS="$(want_check && echo ON || echo OFF)"
	cmake --build build
}

check() {
	ctest -j $JOBS --test-dir build --output-on-failure
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

py() {
	depends="$pkgname=$pkgver-r$pkgrel python3"
	amove usr/bin/onelab.py
}

sha512sums="
8f2a71d6db80dd6bacde6dc1ccd120c7f83609dd69a84a910455a21a43b7392cd7e0e7b4d37aaa6a1b1cbfdb816646cd4828d2ac6d784edba072167280432e4c  gmsh-4.11.1-source.tgz
"
